home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 4 / Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso / Development / Source / MSG Demo 1.4.source Folder / Demo ƒ / Fades reversed ƒ / Circular fade reversed.c next >
Text File  |  1994-04-15  |  4KB  |  130 lines

  1. /**********************************************************************\
  2.  
  3. File:        Circular fade reversed.c
  4.  
  5. Purpose:    Graphic effect to fade main window to solid pattern.
  6.             See comments below for more description.
  7.  
  8. This program is free software; you can redistribute it and/or modify
  9. it under the terms of the GNU General Public License as published by
  10. the Free Software Foundation; either version 2 of the License, or
  11. (at your option) any later version.
  12.  
  13. This program is distributed in the hope that it will be useful,
  14. but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16. GNU General Public License for more details.
  17.  
  18. You should have received a copy of the GNU General Public License
  19. along with this program in a file named "GNU General Public License".
  20. If not, write to the Free Software Foundation, 675 Mass Ave,
  21. Cambridge, MA 02139, USA.
  22.  
  23. \**********************************************************************/
  24.  
  25. #include "timing.h"
  26.  
  27. #define CorrectTime 2
  28. #define theWindowHeight (boundsRect.bottom-boundsRect.top)
  29. #define theWindowWidth (boundsRect.right-boundsRect.left)
  30.  
  31. pascal short CircularFadeReversed(Rect boundsRect, Pattern *thePattern);
  32.  
  33. /* Trace a region from the center to the topleft corner, down <BlockSize> pixels,
  34.    and back to the center.  Fill that in and move the region parameters +BlockSize.
  35.    Repeat for all sides (counterclockwise). */
  36.  
  37. pascal short CircularFadeReversed(Rect boundsRect, Pattern *thePattern)
  38. {
  39.     RgnHandle    curregion, boundsRgn, sectrgn;
  40.     int            cx,cy,lastx,lasty;
  41.     int            BlockSize;
  42.     
  43.     BlockSize=theWindowWidth/40;
  44.     cx = boundsRect.left + theWindowWidth / 2;
  45.     cy = boundsRect.top + theWindowHeight / 2;
  46.  
  47.     boundsRgn=NewRgn();
  48.     RectRgn(boundsRgn, &boundsRect);
  49.     
  50.     sectrgn=NewRgn();
  51.     curregion=NewRgn();
  52.     lasty=boundsRect.top;
  53.     do                                            /* left quadrant */
  54.     {
  55.         StartTiming();
  56.         SetEmptyRgn(curregion);
  57.         MoveTo(cx,cy);
  58.         OpenRgn();
  59.             LineTo(boundsRect.left,lasty);
  60.             Line(0, BlockSize);
  61.             LineTo(cx,cy);
  62.         CloseRgn(curregion);
  63.         SectRgn(curregion, boundsRgn, sectrgn);
  64.         FillRgn(sectrgn, *thePattern);
  65.         lasty+=BlockSize;
  66.         TimeCorrection(CorrectTime);
  67.     }
  68.     while (lasty<boundsRect.bottom);
  69.     
  70.     lastx=boundsRect.left;
  71.     do                                            /* bottom quadrant */
  72.     {
  73.         StartTiming();
  74.         SetEmptyRgn(curregion);
  75.         MoveTo(cx,cy);
  76.         OpenRgn();
  77.             LineTo(lastx,boundsRect.bottom);
  78.             Line(BlockSize, 0);
  79.             LineTo(cx,cy);
  80.         CloseRgn(curregion);
  81.         SectRgn(curregion, boundsRgn, sectrgn);
  82.         FillRgn(sectrgn, *thePattern);
  83.         lastx+=BlockSize;
  84.         TimeCorrection(CorrectTime);
  85.     }
  86.     while (lastx<boundsRect.right);
  87.     
  88.     lasty=boundsRect.bottom;
  89.     do                                            /* right quadrant */
  90.     {
  91.         StartTiming();
  92.         SetEmptyRgn(curregion);
  93.         MoveTo(cx,cy);
  94.         OpenRgn();
  95.             LineTo(boundsRect.right,lasty);
  96.             Line(0,-BlockSize);
  97.             LineTo(cx,cy);
  98.         CloseRgn(curregion);
  99.         SectRgn(curregion, boundsRgn, sectrgn);
  100.         FillRgn(sectrgn, *thePattern);
  101.         lasty-=BlockSize;
  102.         TimeCorrection(CorrectTime);
  103.     }
  104.     while (lasty>boundsRect.top-BlockSize);
  105.     
  106.     lastx=boundsRect.right;
  107.     do                                            /* top quadrant */
  108.     {
  109.         StartTiming();
  110.         SetEmptyRgn(curregion);
  111.         MoveTo(cx,cy);
  112.         OpenRgn();
  113.             LineTo(lastx,boundsRect.top);
  114.             Line(-BlockSize,0);
  115.             LineTo(cx,cy);
  116.         CloseRgn(curregion);
  117.         SectRgn(curregion, boundsRgn, sectrgn);
  118.         FillRgn(sectrgn, *thePattern);
  119.         lastx-=BlockSize;
  120.         TimeCorrection(CorrectTime);
  121.     }
  122.     while (lastx>boundsRect.left-BlockSize);
  123.     
  124.     DisposeRgn(curregion);
  125.     DisposeRgn(boundsRgn);
  126.     DisposeRgn(sectrgn);
  127.     
  128.     return 0;
  129. }
  130.